﻿// See https://aka.ms/new-console-template for more information
using System;

namespace Shape
{
    interface IShape
    {
        double GetArea();
        bool IsValid();
    }

    public class Rectangle : IShape
    {
        double width;
        double height;

        public Rectangle(double width, double height)
        {
            this.width = width;
            this.height = height;
        }

        public double GetArea()
        {
            return width * height;
        }

        public bool IsValid()
        {
            return (width > 0 && height > 0);
        }

        public double Width
        {
            get { return width; }
            set { width = value; }
        }
        public double Height
        {
            get { return height; }
            set { height = value; }
        }
    }

    public class Square : Rectangle
    {
        public Square(double len): base(len, len) {}
        
        public new bool IsValid()
        {
            return (Width == Height) && (Height > 0);
        }
    }

    public class Triangle : IShape
    {
        private double a;
        private double b;
        private double c;

        public Triangle(double a, double b, double c)
        {
            this.a = a;
            this.b = b;
            this.c = c;
        }

        public bool IsValid()
        {
            bool flag1 =  (a > 0 && b > 0 && c > 0);
            bool flag2 = (a + b > c && Math.Abs(a - b) < c);
            return flag1 && flag2;
        }
        public double GetArea()
        {
            double p = (a + b + c) / 2;
            return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
        }
        public double A
        {
            get { return a; }
            set { a = value; }
        }
        public double B
        {
            get { return b; }
            set { b = value; }
        }

        public double C
        {
            get { return c; }
            set
            {
                c = value;
            }
        }
    }

    class Solution
    {
        static void Main(string[] args)
        {

        }
    }
}
